﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class Stasis: BuffAction
    {
        private int healthPerCycle;

        public Stasis(Character c, bool persistant, int row, int colEnd, int count, int lockoutLevel, string name, int duration, bool isBuff, int hPC)
            : base(c, persistant, row, colEnd, count, lockoutLevel, name, duration, false)
        {
            this.healthPerCycle = hPC;
        }

        public override void DoAction(GameController gc)
        {
            if (Core.TimerTicks(timer) == 0 && !IsActive)
            {
                Core.StartTimer(timer);
                IsActive = true;
                GlobalConst.Utils.ActivateAnimationRow(c.ObjectSprite, row + c.offSetSpriteRow(), colEnd, count);
                foreach (Ability a in c.CurrentSet.SetOfAbilities)
                    if (!a.AbilityAction.Immune)
                        a.AbilityAction.Reset(gc);
                c.Buffs.Add(this);
                
            }

            if (Core.TimerTicks(timer) < duration)
            {
                c.GlobalLockout = true;
                if (c.Health < c.maxHealth) c.health += healthPerCycle;
            }
            else if (Core.TimerTicks(timer) > duration)
                Reset(gc);
        }

        public override void Reset(GameController gc)
        {
            Core.StopTimer(timer);
            IsActive = false;
            c.GlobalLockout = false;
        }
    }
}
